package cn.lichenfei.fxui.examples;

import cn.lichenfei.fxui.common.SimpleControl;
import cn.lichenfei.fxui.controls.CFCheckBox;
import cn.lichenfei.fxui.controls.CFRadioButton;
import cn.lichenfei.fxui.controls.CFSwitch;
import cn.lichenfei.fxui.controls.CFTextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import org.kordamp.ikonli.antdesignicons.AntDesignIconsOutlined;
import org.kordamp.ikonli.javafx.FontIcon;

// 表单组件
public class FormExample extends StackPane {

    GridPane gridPane = new GridPane();

    //
    public FormExample() {
        getChildren().add(gridPane);
        gridPane.setMaxHeight(Double.NEGATIVE_INFINITY);
        gridPane.setMaxWidth(Double.NEGATIVE_INFINITY);
        gridPane.setVgap(30);
        gridPane.setHgap(30);

        gridPane.add(SimpleControl.getLabel("单选框", SimpleControl.LabelEnum.H2), 0, 0, 3, 1);
        //单选框
        ToggleGroup tg = new ToggleGroup();
        CFRadioButton cfRadioButton1 = new CFRadioButton("单选框");
        cfRadioButton1.setToggleGroup(tg);
        CFRadioButton cfRadioButton2 = new CFRadioButton("单选框");
        cfRadioButton2.setSelected(true);
        cfRadioButton2.setToggleGroup(tg);
        CFRadioButton cfRadioButton3 = new CFRadioButton("单选框");
        cfRadioButton3.setToggleGroup(tg);
        gridPane.add(cfRadioButton1, 0, 1);
        gridPane.add(cfRadioButton2, 1, 1);
        gridPane.add(cfRadioButton3, 2, 1);

        gridPane.add(SimpleControl.getLabel("复选框", SimpleControl.LabelEnum.H2), 0, 2, 3, 1);
        //复选框
        CFCheckBox cfCheckBox1 = new CFCheckBox("复选框");
        CFCheckBox cfCheckBox2 = new CFCheckBox("复选框");
        CFCheckBox cfCheckBox3 = new CFCheckBox("复选框");
        cfCheckBox3.setSelected(true);
        gridPane.add(cfCheckBox1, 0, 3);
        gridPane.add(cfCheckBox2, 1, 3);
        gridPane.add(cfCheckBox3, 2, 3);

        gridPane.add(SimpleControl.getLabel("开关", SimpleControl.LabelEnum.H2), 0, 4, 3, 1);
        //开关组件
        CFSwitch cfSwitch1 = new CFSwitch();
        CFSwitch cfSwitch2 = new CFSwitch(true);
        CFSwitch cfSwitch3 = new CFSwitch(true, "开关");
        gridPane.add(cfSwitch1, 0, 5);
        gridPane.add(cfSwitch2, 1, 5);
        gridPane.add(cfSwitch3, 2, 5);

        //输入框
        gridPane.add(SimpleControl.getLabel("输入框", SimpleControl.LabelEnum.H2), 0, 6, 3, 1);
        CFTextField cfTextField1 = new CFTextField(CFTextField.Type.TEXT, FontIcon.of(AntDesignIconsOutlined.MAIL));
        CFTextField cfTextField2 = new CFTextField(CFTextField.Type.PASSWORD);
        HBox cfTextFieldHBox = new HBox(cfTextField1, cfTextField2);
        cfTextFieldHBox.setSpacing(10);
        gridPane.add(cfTextFieldHBox, 0, 7, 3, 1);

    }

}